package com.itcam.iostream;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * Author:Cammy.Wu
 * Date:2024-05-13
 * Description:利用DataInputStream向内读入变量
 */

public class DataStreamDemo02 {
    public static void main(String[] args) throws IOException {
        // DataInputStream:将文件中存储的基本数据类型和字符串写入内存的变量中
        DataInputStream dis = new DataInputStream(new FileInputStream(new File("E:\\IOStream\\DataStream01.txt")));

        // 将文件中内容读入程序中
        System.out.println(dis.readUTF());
        System.out.println(dis.readBoolean());
        System.out.println(dis.readDouble());
        System.out.println(dis.readInt());

        // 关闭流
        dis.close();
    }
}
